// Gramatica: APLICACION
//Primer Practica de Compi 2, 2do. Semestre 2011

package C;

//import Bitacora.*;

import java_cup.runtime.Symbol;

%%

%public
%class EscanerC
%cup
%char
%line
%column
%full


%eofval{

			return new Symbol(SimbolosC.EOF, yyline+1, yycolumn +1, yytext());				
		
%eofval}




	LineTerminator = \r|\n|\r\n
	InputCharacter = [^\r\n]

// Comentarios

	Comment = {TraditionalComment} | {EndOfLineComment} 
	TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
	EndOfLineComment = "//" {InputCharacter}* {LineTerminator}



// Tokens

	letras			= [a-zA-Z]
	identificador 	= [_]*{letras} | [_]*{letras} [_]*[a-zA-Z0-9]*

	numero 			= 0 | [1-9][0-9]*

	new_line 		= \r|\n|\r\n;

	white_space 	= {new_line} | [ \t\f]
	
	// charT			= [a-z] | [A-Z] | [0-9]
	

%%

{Comment}	    { /* ignoramos comentarios */ }		
// {charT}			{
						// return new Symbol(SimbolosC.VCHAR, yyline+1, yycolumn +1, yytext()); 	
				// }
"import"		{
						return new Symbol(SimbolosC.IMPORT, yyline+1, yycolumn +1, yytext()); 	
				}
"class"			{
						return new Symbol(SimbolosC.CLASE, yyline+1, yycolumn +1, yytext()); 	
				}
"public"		{
						return new Symbol(SimbolosC.PUBLIC, yyline+1, yycolumn +1, yytext()); 	
				}
"private"		{
						return new Symbol(SimbolosC.PRIVATE, yyline+1, yycolumn +1, yytext()); 	
				}
"protected"		{
						return new Symbol(SimbolosC.PROTECTED, yyline+1, yycolumn +1, yytext()); 	
				}
"extends"		{
						return new Symbol(SimbolosC.EXTENDS, yyline+1, yycolumn +1, yytext()); 	
				}				
"String"		{
						return new Symbol(SimbolosC.STRING, yyline+1, yycolumn +1, yytext()); 	
				}				
"int"			{
						return new Symbol(SimbolosC.INT, yyline+1, yycolumn +1, yytext()); 	
				}				
"char"			{
						return new Symbol(SimbolosC.CHAR, yyline+1, yycolumn +1, yytext()); 	
				}				
"boolean"		{
						return new Symbol(SimbolosC.BOOLEAN, yyline+1, yycolumn +1, yytext()); 	
				}				
"float"			{
						return new Symbol(SimbolosC.FLOAT, yyline+1, yycolumn +1, yytext()); 	
				}	
"null"			{
						return new Symbol(SimbolosC.NULL, yyline+1, yycolumn +1, yytext()); 	
				}	
"void"			{
						return new Symbol(SimbolosC.VOID, yyline+1, yycolumn +1, yytext()); 	
				}
"disparar"		{
						return new Symbol(SimbolosC.DISPARAR, yyline+1, yycolumn +1, yytext()); 	
				}
"girar"			{
						return new Symbol(SimbolosC.GIRAR, yyline+1, yycolumn +1, yytext()); 	
				}
"robotDetectado" {
						return new Symbol(SimbolosC.ROBOT_DETECTADO, yyline+1, yycolumn +1, yytext()); 	
				}
"chocar"		{
						return new Symbol(SimbolosC.CHOCAR, yyline+1, yycolumn +1, yytext()); 	
				}
"adelante"		{
						return new Symbol(SimbolosC.ADELANTE, yyline+1, yycolumn +1, yytext()); 	
				}
"atras"			{
						return new Symbol(SimbolosC.ATRAS, yyline+1, yycolumn +1, yytext()); 	
				}
"fin"			{
						return new Symbol(SimbolosC.FIN, yyline+1, yycolumn +1, yytext()); 	
				}
"imprimir"		{
						return new Symbol(SimbolosC.IMPRIMIR, yyline+1, yycolumn +1, yytext()); 	
				}
"getEnergia"	{
						return new Symbol(SimbolosC.GET_ENERGIA, yyline+1, yycolumn +1, yytext()); 	
				}
"return"		{
						return new Symbol(SimbolosC.RETURN, yyline+1, yycolumn +1, yytext()); 	
				}
"true"			{
						return new Symbol(SimbolosC.TRUE, yyline+1, yycolumn +1, yytext()); 	
				}
"false"			{
						return new Symbol(SimbolosC.FALSE, yyline+1, yycolumn +1, yytext()); 	
				}				
"if"			{
						return new Symbol(SimbolosC.IF, yyline+1, yycolumn +1, yytext()); 	
				}
"else"			{
						return new Symbol(SimbolosC.ELSE, yyline+1, yycolumn +1, yytext()); 	
				}
"do"			{
						return new Symbol(SimbolosC.DO, yyline+1, yycolumn +1, yytext()); 	
				}				
"while"			{
						return new Symbol(SimbolosC.WHILE, yyline+1, yycolumn +1, yytext()); 	
				}
"for"			{
						return new Symbol(SimbolosC.FOR, yyline+1, yycolumn +1, yytext()); 	
				}
"switch"		{
						return new Symbol(SimbolosC.SWITCH, yyline+1, yycolumn +1, yytext()); 	
				}
"case"			{
						return new Symbol(SimbolosC.CASE, yyline+1, yycolumn +1, yytext()); 	
				}	
"default"		{
						return new Symbol(SimbolosC.DEFAULT, yyline+1, yycolumn +1, yytext()); 	
				}	
"break"			{
						return new Symbol(SimbolosC.BREAK, yyline+1, yycolumn +1, yytext()); 	
				}	
"this"			{
						return new Symbol(SimbolosC.THIS, yyline+1, yycolumn +1, yytext()); 	
				}	

"in"			{
						return new Symbol(SimbolosC.IN, yyline+1, yycolumn +1, yytext()); 	
				}
"end"			{
						return new Symbol(SimbolosC.END, yyline+1, yycolumn +1, yytext()); 	
				}	
"def"			{
						return new Symbol(SimbolosC.DEF, yyline+1, yycolumn +1, yytext()); 	
				}	

"main"			{
						return new Symbol(SimbolosC.MAIN, yyline+1, yycolumn +1, yytext()); 	
				}				
"-"{numero}	| {numero}		{
						return new Symbol(SimbolosC.NUMERO, yyline+1, yycolumn +1, yytext()); 	
				}	
	
			
{identificador} {
						return new Symbol(SimbolosC.ID, yyline+1, yycolumn +1, yytext()); 	
				}


"&"				{
						return new Symbol(SimbolosC.REF, yyline+1, yycolumn +1, yytext()); 	
				}				
";"				{
						return new Symbol(SimbolosC.PUNTO_COMA, yyline+1, yycolumn +1, yytext()); 	
				}
":"				{
						return new Symbol(SimbolosC.DOS_PUNTOS, yyline+1, yycolumn +1, yytext()); 	
				}
"["				{
						return new Symbol(SimbolosC.CORCHETEA, yyline+1, yycolumn +1, yytext()); 	
				}
"]"				{
						return new Symbol(SimbolosC.CORCHETEC, yyline+1, yycolumn +1, yytext()); 	
				}	
"("				{
						return new Symbol(SimbolosC.PARENTESISA, yyline+1, yycolumn +1, yytext()); 	
				}
")"				{
						return new Symbol(SimbolosC.PARENTESISC, yyline+1, yycolumn +1, yytext()); 	
				}
"{"				{
						return new Symbol(SimbolosC.LLAVEA, yyline+1, yycolumn +1, yytext()); 	
				}
"}"				{
						return new Symbol(SimbolosC.LLAVEC, yyline+1, yycolumn +1, yytext()); 	
				}	
"="				{
						return new Symbol(SimbolosC.IGUAL, yyline+1, yycolumn +1, yytext()); 	
				}
"\""			{
						return new Symbol(SimbolosC.DCOMILLA, yyline+1, yycolumn +1, yytext()); 	
				}
"'"				{
						return new Symbol(SimbolosC.COMILLA, yyline+1, yycolumn +1, yytext()); 	
				}
","				{
						return new Symbol(SimbolosC.COMA, yyline+1, yycolumn +1, yytext()); 	
				}
"."				{
						return new Symbol(SimbolosC.PUNTO, yyline+1, yycolumn +1, yytext()); 	
				}
".."				{
						return new Symbol(SimbolosC.DPUNTO, yyline+1, yycolumn +1, yytext()); 	
				}
"||"			{
						return new Symbol(SimbolosC.OR, yyline+1, yycolumn +1, yytext()); 	
				}
"&&"			{
						return new Symbol(SimbolosC.AND, yyline+1, yycolumn +1, yytext()); 	
				}	
"=="			{
						return new Symbol(SimbolosC.EQUAL, yyline+1, yycolumn +1, yytext()); 	
				}
"<"				{
						return new Symbol(SimbolosC.MENOR, yyline+1, yycolumn +1, yytext()); 	
				}
"<="			{
						return new Symbol(SimbolosC.MENOR_IGUAL, yyline+1, yycolumn +1, yytext()); 	
				}	
"<>"			{
						return new Symbol(SimbolosC.NOT_EQUAL, yyline+1, yycolumn +1, yytext()); 	
				}
">"				{
						return new Symbol(SimbolosC.MAYOR, yyline+1, yycolumn +1, yytext()); 	
				}
">="			{
						return new Symbol(SimbolosC.MAYOR_IGUAL, yyline+1, yycolumn +1, yytext()); 	
				}
"+"				{
						return new Symbol(SimbolosC.MAS, yyline+1, yycolumn +1, yytext()); 	
				}
"++"				{
						return new Symbol(SimbolosC.INC, yyline+1, yycolumn +1, yytext()); 	
				}
"-"				{
						return new Symbol(SimbolosC.MENOS, yyline+1, yycolumn +1, yytext()); 	
				}
"--"				{
						return new Symbol(SimbolosC.DEC, yyline+1, yycolumn +1, yytext()); 	
				}
"*"				{
						return new Symbol(SimbolosC.MULT, yyline+1, yycolumn +1, yytext()); 	
				}		
"/"				{
						return new Symbol(SimbolosC.DIV, yyline+1, yycolumn +1, yytext()); 	
				}	
"%"				{
						return new Symbol(SimbolosC.MOD, yyline+1, yycolumn +1, yytext()); 	
				}				
"+="			{
						return new Symbol(SimbolosC.MAS_IGUAL, yyline+1, yycolumn +1, yytext()); 	
				}				
"-="			{
						return new Symbol(SimbolosC.MENOS_IGUAL, yyline+1, yycolumn +1, yytext()); 	
				}	
"*="			{
						return new Symbol(SimbolosC.MULT_IGUAL, yyline+1, yycolumn +1, yytext()); 	
				}				
"%="			{
						return new Symbol(SimbolosC.MOD_IGUAL, yyline+1, yycolumn +1, yytext()); 	
				}
{white_space}   { /* ignoramos espacios */ }




.|\n              { 	    
					System.err.println("Caracter No definido > "+ yytext()+" <"+ " linea "+ (yyline+1) + " Columna "+ (yycolumn+1) + " col final "+ yychar);			
					
					//IDE.Face.errores_lexicos.add(new Info(yytext(),yyline+1,yycolumn+1,0,"Token No Admitido", "Lexico"));
					
					//IDE.Inicio.msj.setText("ERROR lexico: "+"Caracter No definido: "+ yytext()+", "+ " linea "+ (yyline+1) + " Columna "+ (yycolumn+1)+ "\n");
					
                  }

 

